package org.jfarrell.videoserver;

import javax.media.*;
import javax.media.rtp.event.*;
import javax.media.util.*;
import javax.media.format.*;
import javax.media.protocol.*;
import javax.media.control.*;
import javax.media.rtp.*;

import com.sun.media.*;
import com.sun.media.rtp.*;

import java.net.*;

import java.util.Vector;

public class VideoServer implements SendStreamListener
{
	private String m_source, m_session, m_port;
	private VideoTransmit m_vt;
	
	public VideoServer(String destIp, String destPort)
	{
		this.m_source = "vfw://0";
		this.m_session = destIp;/*"148.61.225.90";*/
		this.m_port = destPort;/*"22224";*/
		
		this.m_vt = new VideoTransmit(
				new MediaLocator(this.m_source),
				this.m_session, this.m_port);
		
		String result = this.m_vt.start();
		if (result != null) {
			System.out.println( "Failed: " + result );
			System.exit(0);
		}
		
		System.out.println( "Streaming" );
	}
	
	public void update(SendStreamEvent ev)
	{
		System.out.println( "Stream Sent" );
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		if (args.length != 2) {
			System.out.println( "Command Usage: java VideoServer <destIp> <destPort>" );
			System.exit(0);
		}
		
		VideoServer main_server = new VideoServer(args[0], args[1]);
	}

}
